#include "platform.h"
#include "Watch.h"

Watch::Watch(void)
{
	Reset();
}

void Watch::Start() {
	_startTime = GetTime();
	_isRunning = true;
}

void Watch::Stop() {
	_stopTime = GetTime();
	_isRunning = false;
}

void Watch::Reset(){
	_startTime = _stopTime = 0;
	_isRunning = false;
}

int Watch::GetElapsedTime(){
	if(_isRunning){
		return GetTime() - _startTime;
	}
	return _stopTime - _startTime;
}

inline int Watch::GetTime() {
  struct _timeb t;
  _ftime(&t);
  return int(t.time * 1000 + t.millitm);
}
